package com.ysm.smfu.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.ysm.smfu.R;
import com.ysm.smfu.bean.PayBusinessInfo;
import com.ysm.smfu.bean.PayResult;
import com.ysm.smfu.contans.SpKey;
import com.ysm.smfu.fragment.PaySuccessFragment;
import com.ysm.smfu.fragment.XiangqingFragment;
import com.ysm.smfu.utils.PrintUtil;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2016/10/15.
 */
public class XiangQingActivity extends BaseActivity {

    @BindView(R.id.title_body)
    TextView titleBody;
    @BindView(R.id.mainActivity_topbar_img)
    ImageView mainActivityTopbarImg;


    private int xiangqing;
    private PayResult payResult;
    private PayBusinessInfo payBusinessInfo;

    @Override
    protected void init() {
        super.init();
        xiangqing = getIntent().getIntExtra("xiangqing", -1);
        payResult = (PayResult) getIntent().getSerializableExtra(SpKey.PAYRESULT);
        payBusinessInfo = (PayBusinessInfo) getIntent().getSerializableExtra(SpKey.PAYBUSINESSINFO);
        if (payResult != null)
            PrintUtil.printRespones("详情页" + payResult.toString());
        if (payBusinessInfo != null)
            PrintUtil.printRespones("详情页" + payBusinessInfo.toString());
    }


    @Override
    protected void initViews() {
        super.initViews();
        setContentView(R.layout.activity_xiangqing);
        ButterKnife.bind(this);
        mainActivityTopbarImg.setVisibility(View.GONE);
    }

    Fragment fragment;

    @Override
    protected void initData() {
        super.initData();
        Bundle bundle = new Bundle();
        switch (xiangqing) {
            case 0:
                titleBody.setText("账单详情");
                //设置数据---查看账单详情
                fragment = new XiangqingFragment();
                bundle.putSerializable(SpKey.PAYBUSINESSINFO, payBusinessInfo);
                fragment.setArguments(bundle);
                break;
            case 1:
                titleBody.setText("付款结果");
//                支付成功界面
                fragment = new PaySuccessFragment();
                bundle.putSerializable(SpKey.PAYRESULT, payResult);
                fragment.setArguments(bundle);
                break;
        }
        getSupportFragmentManager().beginTransaction().replace(R.id.xiangqingContainer, fragment).commit();
    }
}
